<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
  <title>Document</title>
  <style>
    .weapon {
      width: 100px;
      height: 100px;
      background-color: red;
      transform: scale();
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="weapon" :style="{'transform':'scale('+time+')'}"></div>
    <br>
    <br>
    <br>
    <input type="text" v-model="val1.name">
    <input type="text" v-model="val2">
    <p>{{sum}}</p>
    <hr>
    <button @click="change">chage</button>
    <transition
      enter-active-class="animate__bounceIn"
      leave-active-class="animate__bounceOut"
      >
      <p v-show="isShow">1234567890</p>
    </transition>
    <hr>
    <button @click="changeCom">切换组件</button>
    <keep-alive>
      <div :is="comName"></div>
    </keep-alive>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        time: 1.5,
        val1: {
          name: 'aaa'
        },
        val2: '',
        num1: 100,
        num2: 200,
        isShow: true,
        comName: 'student'
      },
      components: {
        'teacher': {
          template: `
            <div>
              <p>teacher</p>
              <input />
            </div>
          `
        },
        'student': {
          template: `
            <div>
              <p>student</p>
              <input />
            </div>
          `
        }
      },
      computed: {
        sum: {
          get() {
            console.log(111);
            return this.num1 + this.num2
          },
          set() {
            console.log(222);
          }
        }
      },
      watch: {
        val1: {
          handler(newVal, oldVal) {
            console.log(4444,newVal, oldVal);
          },
          // deep: true
        }
      },
      methods: {
        change() {
          this.isShow = !this.isShow
          console.log(this.isShow);
        },
        changeCom() {
          this.comName == 'teacher'? this.comName = 'student':this.comName = 'teacher'
        }
      },
    })
  </script>
</body>
</html>